package com.pine.dbant.core.model.dto;

import com.pine.dbant.common.plugin.ExecuteParams;
import com.pine.dbant.common.plugin.QueryExecuteParams;
import lombok.Getter;
import lombok.Setter;
import org.springframework.beans.BeanUtils;

import javax.validation.constraints.NotBlank;
import java.util.Map;

/**
 * @author xiaoyuan
 * @create 2022/11/30 10:57
 **/
@Setter
@Getter
public class ExecuteParamsDTO {

    /**
     * 执行脚本
     */
    @NotBlank(message = "脚本不能为空")
    private String script;
    /**
     * 执行参数
     */
    private Map<String, Object> properties;
    /**
     * 页码
     */
    private Integer pageIndex = 1;
    /**
     * 每次查询数量
     */
    private Integer pageSize = 10;
    /**
     * 查询条件
     */
    private String whereCriteria;

    /**
     * 排序条件
     */
    private String orderCriteria;
    /**
     * 是否进行分页查询：分页将返回更少的数据
     */
    private boolean noPage = false;


    public ExecuteParams toExecuteParams() {
        QueryExecuteParams queryExecuteParams = new QueryExecuteParams();
        BeanUtils.copyProperties(this, queryExecuteParams);
        return queryExecuteParams;
    }
}
